#ifndef TBUTTONDELEGATE_H
#define TBUTTONDELEGATE_H

#include <QSqlRelationalDelegate>
#include <QPushButton>
#include <QMouseEvent>

class TButtonDelegate : public QSqlRelationalDelegate
{
    Q_OBJECT
public:
    explicit TButtonDelegate(QSqlRelationalDelegate *parent = nullptr);


    // QAbstractItemDelegate interface
public:
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);

signals:
    void clicked(int row);  //发出点击信号，并传出当前行

    // QAbstractItemDelegate interface
private:
    bool *btnPress;
};

#endif // TBUTTONDELEGATE_H
